package com.ssm.admin.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ssm.admin.entity.SsmGoodstypeEntity;
import com.ssm.admin.service.SsmGoodstypeService;
import com.ssm.common.utils.PageUtils;
import com.ssm.common.utils.R;



/**
 * 
 *
 * @author ssm
 * @email sunlightcs@gmail.com
 * @date 2023-03-19 17:30:08
 */
@RestController
@RequestMapping("admin/ssmgoodstype")
public class SsmGoodstypeController {
    @Autowired
    private SsmGoodstypeService ssmGoodstypeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = ssmGoodstypeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{goodsType}")
    public R info(@PathVariable("goodsType") Integer goodsType){
		SsmGoodstypeEntity ssmGoodstype = ssmGoodstypeService.getById(goodsType);

        return R.ok().put("ssmGoodstype", ssmGoodstype);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody SsmGoodstypeEntity ssmGoodstype){
		ssmGoodstypeService.save(ssmGoodstype);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody SsmGoodstypeEntity ssmGoodstype){
		ssmGoodstypeService.updateById(ssmGoodstype);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] goodsTypes){
		ssmGoodstypeService.removeByIds(Arrays.asList(goodsTypes));

        return R.ok();
    }

}
